package com.lamper.admin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lamper.admin.entity.UserEntity;
import com.lamper.admin.service.UserService;

@RestController
@RequestMapping("/api")
public class AdminController {

    @Autowired
    private UserService userService;

    @GetMapping("/hello")
    public String sayHello() {
        UserEntity userEntity = new UserEntity();
        userEntity.setName("admin");
        userService.save(userEntity);
        return "Hello, Admin!";
    }

    @GetMapping("/saveOrUpdate")
    public String saveOrUpdate() {
        UserEntity userEntity = new UserEntity();
        userEntity.setId(1921063181954818050L);
        userEntity.setName("NEW GUY");
        userService.saveOrUpdate(userEntity);
        return "Hello, Admin!";
    }
}
